#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<bitset>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define rep(i,a,b) for(register int i = (a);i <= (b);++i)
#define per(i,a,b) for(register int i = (a);i >= (b);--i) 
#define mkp std::make_pair
typedef long long ll;
typedef unsigned long long ull;
using std::string;using std::cin;using std::cout;
inline bool cmp(int x,int y){return x < y;}

const int N = 3e2+9;
const int inf = 1e9+9;
const double eps = 1e-7;
int _,n,m,a[2*N],u,v,ans;
int dp[2*N][2*N],size[2*N];
int fa[2*N],num[2*N],root , next[2*N],ver[2*N],head[2*N],tot;
int fix;
inline void link(int x,int y){ver[++tot] = y , next[tot] = head[x] , head[x] = tot;}
inline int find(int i){return fa[i] == i ? i : find(fa[i]);}

inline void dfs(int now){
    size[now] = 1;
    for(int i = head[now];i;i = next[i]){
        if(ver[i] == fa[now]) continue;
        dfs(ver[i]);
        size[now] += size[ ver[i] ] , ++num[now];
    }
    dp[now][0] = 0 , dp[now][1] = 1 , dp[now][ size[now] ] = 1 , dp[now][ size[now] - 1 ] = num[now];
    if(!num[now]) return;//叶子回溯
    for(int son = head[now];son;son = next[son]){//枚举儿子
        int i = ver[son];
        per(j,size[now]-1,1){
            rep(k,1,size[i]){
                if(j-k < 0) break;
                dp[now][j] = std::min(dp[now][j] , dp[now][j-k] + dp[i][k]);
            }
        }
    }
}

int main(){
    std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef LOCAL //use "g++ xxx.cpp -DLOCAL"
        freopen("in.in", "r", stdin);
    #endif
    cin >> n >> m;
    rep(i,0,n+1) fa[i] = i;
    rep(i,1,n) rep(j,1,n) dp[i][j] = inf;
    rep(i,1,n-1){
        cin >> u >> v;
        fa[v] = u;
        link(u,v);
    }
    root = find(1) , ans = inf;
    // std::cerr << "root is " << root << "\n"; // checked
    dfs(1);
    rep(i,1,n) rep(j,0,n){
        if(j > size[i]) continue;
        // cout <<? "dp[" << i << "][" << j << "] = " << dp[i][j] << "\n"; // checked
        if(i == root) if(n-j==m){ans = std::min(ans,dp[root][size[i]-m]);break;}
        if(n - j == m ){ ans = std::min(ans,dp[i][j]);}
        if(size[i] - j == m){ ans = std::min(ans,dp[i][j]+1);}
    }
    cout << ans << "\n";
    return 0;
}